<?php

include("update-lookup.php");
include("../rest/database.php");
include("../rest/database_info.php");


$list = doGetListResult("SELECT refno AS id, fn1 AS name, str AS street, zip, city FROM busiquest WHERE res4 IS NULL OR res4 = '' OR res5 IS NULL OR res5 = '' LIMIT 100");
$notFound = "";

foreach ($list as $key => $entry) {
	$id = $entry->id; // is this the ID?
	$address = $entry->street.", ".$entry->zip." ".$entry->city;
	$lookup = lookup($address);
	if ($lookup == null) {
		$notFound = $notFound."<b>".$entry->name.": $address NOT FOUND!!!</b></br>";
		continue;
	}
	echo "UPDATE busiquest SET res4 = '".$lookup["latitude"]."', res5 = '".$lookup["longitude"]."' WHERE refno = '$id'; \n</br>";
}

echo "<br><i>Finished.</i></br></br>";
echo $notFound;

?>